package cn.sciento.iam.infra.repository.impl;

import cn.sciento.core.base.BaseConstants;
import cn.sciento.iam.api.dto.SubModuleDTO;
import cn.sciento.iam.domain.entity.SubModule;
import cn.sciento.iam.domain.entity.Tenant;
import cn.sciento.iam.domain.repository.SubModuleRepository;
import cn.sciento.iam.infra.mapper.SubModuleMapper;
import cn.sciento.mybatis.base.impl.BaseRepositoryImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;

import java.util.List;

/**
 * 子模块的管理

 */
@Component
public class SubModuleRepositoryImpl extends BaseRepositoryImpl<SubModule> implements SubModuleRepository {

    private final SubModuleMapper subModuleMapper;

    public SubModuleRepositoryImpl(SubModuleMapper subModuleMapper) {
        this.subModuleMapper = subModuleMapper;
    }



    @Override
    public List<SubModule> listSubModule(SubModuleDTO subModule){
        Long tenantId = subModule.getTenantId();
        Assert.notNull(tenantId, "hiam.error.tenant.notFound");
        return subModuleMapper.listSubModule(subModule);

    }

    @Override
    public List<SubModule> selectRoleModule(List<Long> roleIdList, Long tenantId) {
        return subModuleMapper.selectRoleModule(roleIdList,tenantId);
    }
}
